package com.titaniue.java1;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @program: JavaSenior
 * @description: URL 网络编程
 * 1.URL统一资源定位符，对应互联网的某一个资源地址
 * 2.格式 http://localhost:8080/examples/beaty.jpg?username=xxx
 *        协议    主机名  端口号   资源地址           参数列表
 * @author: renfei.huang
 * @create: 2021-10-26 22:52
 */
public class URLTest {

    public static void main(String[] args) throws MalformedURLException {

        URL url = new URL("http://localhost:8080/examples/beaty.jpg?username=xxx");

        System.out.println("getProtocol() :"+url.getProtocol());
        System.out.println("getHost() :"+url.getHost());
        System.out.println("getPort() :"+url.getPort());
        System.out.println("getPath() :"+url.getPath());
        System.out.println("getFile() :"+url.getFile());
        System.out.println("getQuery() :"+url.getQuery());
    }
}
